package com.hhit.bigscreenbackmanage.controller.jsgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.entity.jsgl.TJsglGljh;
import com.hhit.bigscreenbackmanage.service.jsgl.TJsglGljhService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/jsgl/gljh")
public class GljhController {

    private Logger log = LoggerFactory.getLogger(GljhController.class);

    @Autowired
    TJsglGljhService tJsglGljhService;

    /**
     * 新增管理计划
     * @param tJsglGljh
     * @return
     */
    @RequestMapping("/importGljh")
    public Response importGljh(@RequestBody TJsglGljh tJsglGljh){
        try{
            tJsglGljhService.importGljh(tJsglGljh);
            return Response.createResponseBySuccess("管理计划导入成功");
        }catch (Exception e){
            log.error("管理计划导入失败: " + e.getMessage());
            return Response.createResponseByError("管理计划导入失败");
        }
    }

    /**
     * 查询管理计划
     * @param jsonObject
     * @return
     */
    @RequestMapping("/queryGljh")
    public Response queryGljh(@RequestBody JSONObject jsonObject){
        try{
            List<TJsglGljh> result = tJsglGljhService.queryGljh(jsonObject);
            return Response.createResponseBySuccess("查询管理计划成功",result);
        }catch (Exception e){
            log.error("查询管理计划失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询管理计划失败");
        }
    }
}
